package org.bitmaps.cutBitmap.tool
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.geom.ColorTransform;
	import flash.geom.Rectangle;

	public class DrawArrow extends DrawRect
	{
		private var _arrow:Sprite;
		private var arrowColor:uint = 0;
		public function DrawArrow($bound:Rectangle)
		{
			super($bound);
			type = 3;
			
			_arrow = new Sprite();
			_arrow.graphics.beginFill(color);
			_arrow.graphics.lineTo(-10,-5);
			_arrow.graphics.lineTo(-10,5);
			_arrow.graphics.lineTo(0,0);
			_arrow.graphics.endFill();
			arrowColor = color;
		}
		
		override protected function draw():void
		{
			_graphics.graphics.clear();
			_graphics.graphics.lineStyle(1,color);
			_graphics.graphics.moveTo(_startPoint.x,_startPoint.y);
			_graphics.graphics.lineTo(_endPoint.x,_endPoint.y);
			if(!_arrow.parent)
			{
				this.addChild(_arrow);
			}
			_arrow.x = _endPoint.x;
			_arrow.y = _endPoint.y;
			_arrow.rotation = 180*Math.atan2(_endPoint.y-_startPoint.y,_endPoint.x-_startPoint.x)/Math.PI;
			if(arrowColor != color)
			{
				var ct:ColorTransform = new ColorTransform();
				ct.color = color;
				_arrow.transform.colorTransform = ct;
			}
		}
	}
}